﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.SqlClient;
using System.Configuration;

namespace Messenger.DataAccess
{
    /// <summary>
    /// Manage connection to DB Server - This class has ability change to other DB to mysql, oracle...
    /// Created by: Dinh Quoc Vuong
    /// Created date: Sep 30th 2011
    /// </summary>
    public class Connection
    {
        /// <summary>
        /// Get db connection
        /// </summary>
        /// <returns></returns>
        public static DbConnection GetConnection()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["Messenger"].ConnectionString;
            DbConnection dbConnection = new SqlConnection(connectionString);
            return dbConnection;
        }

        /// <summary>
        /// Get db command
        /// </summary>
        /// <returns></returns>
        public static DbCommand GetCommand()
        {   
            DbCommand cmd = GetConnection().CreateCommand();
            return cmd;
        }
    }
}
